#!/bin/bash
# coding: utf-8
#
# title: Replicate results reported in paper, supporting materials, and data appendix
# author: Hauke Licht

# helper functions
ts() { date '+%Y-%m-%dT%H:%M:%S'; }
message() { echo -e "$(ts): $1"; }

# # report R version, platform and OS
# Rscript -e 'sessionInfo()' | head -3

# setup and activate renv
message "Setting up and activating renv"
Rscript --vanilla code/setup_renv.R 1> /dev/null
Rscript --vanilla renv/activate.R 1> /dev/null

# create paper objects
message "Compiling objects required for results reporting"
Rscript --vanilla code/06-report/01-compile_paper_objects.R > /dev/null 2>&1

# create figures and tables
message "Creating figures and tables"
mkdir -p results/figures
mkdir -p results/tables
Rscript --vanilla code/06-report/02-report_results_in_main_paper.R > /dev/null 2>&1
Rscript --vanilla code/06-report/03-report_results_in_supporting_materials.R > /dev/null 2>&1
Rscript --vanilla code/06-report/04-report_results_in_data_appendix.R > /dev/null 2>&1

message "Done!"
